package com.zhou.common.mybatis.template.oss;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import com.zhou.common.base.mq.model.BaseEntity;

import java.util.Collections;

public class CodeGeneratorUpdate {
    public static void main(String[] args) {

        String mysqlUrl = "jdbc:mysql://rm-bp1q616d43xp0d325ro.mysql.rds.aliyuncs" +
                ".com:3306/qinqing-bigdata?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&";
        FastAutoGenerator.create(mysqlUrl, "xx_qinqing", "1qaz@WSX3edc")
                .globalConfig(builder -> {
                    builder.author("zhouxianfeng") // 设置作者
                            .enableSwagger() // 开启 swagger 模式
                            .fileOverride()
                            .outputDir("D:\\workspace-personal2\\my-combine\\common-oss\\src\\test\\java"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("com.zhou.common.oss") // 设置父包名
                            .moduleName("core") // 设置父包模块名
                            .pathInfo(Collections.singletonMap(OutputFile.mapperXml, "D:\\workspace-personal2\\my-combine\\common-oss\\src\\test\\resources")); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.addInclude("oss_temp_file")// 设置需要生成的表名
                            .entityBuilder().enableLombok()
                            .superClass(BaseEntity.class)
                            .addSuperEntityColumns("id","del_flag","creator","created_time","modifier","modified_time")
                    ; // 设置过滤表前缀
                })
                .templateConfig(builder -> {
                    //builder.controller("").service("").serviceImpl("").mapper("").mapperXml("").entity("");
                    builder.controller("").service("").serviceImpl("").mapperXml("");
                })
                .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .execute();
    }
}
